// Redux配置
// 导入redux
import { createStore } from "redux"

// state静态数据状态，存储数据状态地方
let storeState = {
    bookInfo:"javascript入门到放弃",
    num:1
}

// Reducer 由与各action组合而成大方法
// action 由于修改state数据方法，action里面必须包含type类型

let counterReducer = (state,action) => {
    // console.log("Redux-state==>",state);
    // console.log("Redux-action==>",action);

    if(action.type == "set_num"){ //修改num数据
        state.num += 1;

    }else if(action.type == "set_book_name"){ //修改书名
        state.bookInfo = action.data;

    }





    return {...state};//生成新数据
}


// 导出store数据
export const store = createStore(counterReducer,storeState);

// 注意：去配置index.js入口文件